<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件
function p($arr){
    echo "<pre>";
    print_r($arr);
    echo "</pre>";
}

/**
 * 返回json数据
 * @param $list //若失败返回 那么$list=$msg
 * @param string $msg
 * @param int $count
 * @return \think\response\Json
 */
function ajaxReturn($list,$count = null,$msg = ''){
    if(is_array($list) || is_object($list)){
        return json(['code'=>0,'msg'=>$msg,'count'=>$count,'data'=>$list]);
    }else{
        return json(['code'=>1,'msg'=>$list,'count'=>$count,'data'=>$list]);
    }
}

/**
 * 输出log
 * @param array $data
 * @param string $url
 */
function logs($data = [],$url = ''){
    error_log("\r\n".date('Y-m-d H:i:s').'【'.__LINE__.'】 : '.print_r($data,true),3,$url ? : '../runtime/logs/admin.log');
}


//获取Url路由
function get_url_route()
{
    $str = $_SERVER['REQUEST_URI'];
    $str = explode(".",$str);
    return $str[0];
}